set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
# 关闭 session 时不退出 tmux，而是切换到其他 session
set-option -g detach-on-destroy off

set -g mouse on
set -g base-index 1
set -g pane-base-index 1

# 状态栏背景颜色
set -g status-style "bg=default"

# 状态栏窗口列表左对齐
set -g status-justify left

# 状态栏命令行模式下的颜色
set -g message-style "bg=#cb7290,fg=#1e1d28"

# 状态栏窗口名称样式(#I：序号，#w：窗口名称，#F：指示符)
set -wg window-status-current-format "#[fg=#aecdd6,bg=default]#[fg=#1e1d28,bg=#aecdd6]#I:#W#[fg=#aecdd6,bg=default]"
set -wg window-status-format "#[fg=#2a283b,bg=default]#[fg=#6d6a83,bg=#2a283b]#I:#W#[fg=#2a283b,bg=default]"

# 状态栏窗口列表分隔符
#set -wg window-status-separator "#[bg=#242231,fg=#2a283b]|"

set -g status-position bottom
# 状态栏左右样式
set -g status-left ""
set -g status-right "#[fg=#aecdd6,bg=default]#[fg=#1e1d28,bg=#aecdd6]#S#[fg=#aecdd6,bg=default]"

# 列表视图选项样式
set -wg mode-style "bg=#aecdd6,fg=#1e1d28"

# Esc 键响应延时 ms
set -sg escape-time 10

# <prefix>-q 显示编号的驻留时长，单位 ms
set -g display-panes-time 10000 


bind -n M-n select-window -n
bind -n M-p select-window -p

bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9
bind -n M-0 select-window -t 10

bind -n M-q display-panes
bind -n M-w choose-window
bind -n M-s choose-session

#bind -n M-h select-pane -L
#bind -n M-j select-pane -D
#bind -n M-k select-pane -U
#bind -n M-l select-pane -R

# 执行 "tmux list-clients" 查看可用命令
bind -n M-escape last-window
bind -n M-c new-window
bind -n M-r command-prompt
bind -n M-d detach-client


#set -s set-clipboard on  # if your terminal supports OSC 52 clipboard feature
set -s copy-command 'xsel && xsel -o | xsel -b'  # else use X11 clipboard





# Main suggestion
bind-key -n WheelUpPane {
  #select-pane  # this should be consistent with the minor suggestion below
  if-shell -F '#{mouse_any_flag}' {
    send-keys -M  # vim with "set mouse=a" / htop / less with mouse support e.g. "LESS='--mouse --wheel-lines 5' less"
  } {
    if-shell -F '#{alternate_on}' {
      send-keys -N5 Up  # vim with "set mouse=" / man / less without mouse support
    } {
      copy-mode -e
      send-keys -N5 -X scroll-up
    }
  }
}
bind-key -n WheelDownPane {
  #select-pane
  if-shell -F '#{mouse_any_flag}' {
      send-keys -M
  } {
    if-shell -F '#{alternate_on}' {
      send-keys -N5 Down
    }
  }
}

# Minor suggestion
# By removing 'select-pane' command from the default implementation, scrolling wheel on a pane does not make the pane active anymore.
# This behavior is in line with common windowing systems, where an inactive window is scrollable without getting focused.
bind-key -Tcopy-mode WheelUpPane {
  #select-pane
  send-keys -N5 -X scroll-up
}
bind-key -Tcopy-mode WheelDownPane {
  #select-pane
  send-keys -N5 -X scroll-down
}
bind-key -Tcopy-mode-vi WheelUpPane {
  #select-pane
  send-keys -N5 -X scroll-up
}
bind-key -Tcopy-mode-vi WheelDownPane {
  #select-pane
  send-keys -N5 -X scroll-down
}
